<?php
namespace app\common\component\appointment_upstart;

use app\common\model\AppointmentUpstart;

class AppointmentUpstartService {
	public function appointment($data) {
		$data['remaining_price'] = $data['appointment_price'];
		$data['begin_time'] = $data['create_time'] = time();
		$data['to_num'] = 0;
		$data['status'] = 0;

		return $this -> create($data);
	}

	public function create($data) {
		$AppointmentUpstart = new AppointmentUpstart($data);

		if($AppointmentUpstart -> save()) {
			return [
    			'code' => 0,
    			'message' => '土豪区预约成功!',
    			'data' => [
    				'appointment_upstart' => $AppointmentUpstart
    			]
    		];
		}

		return [
			'code' => -1,
			'message' => '土豪区预约失败!'
		];
	}
}
?>